import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            String str=sc.next();
            cha(str);
        }
    }
    public static int money(int n){
        int sum=0;
        int cnt=0;
        int i=1;
        while(cnt<n){
            sum+=i*i;
            cnt+=i;
            i++;
        }
        sum-=(cnt-n)*(--i);
        return sum;
    }
    public static void cha(String str){
        char[] ch=new char[str.length()];
        int i;
        for(i=0;i<str.length();i++){
            ch[i]=str.charAt(i);
        }
        for(i=0;i<str.length()-1;i++){
            if(ch[i]>='a'&&ch[i]<='z'){
                if(ch[i+1]!=ch[i]-32&&ch[i+1]!=ch[i]-1){
                    break;
                }
            }
            if(ch[i]>='A'&&ch[i]<='Z'){
                if(ch[i+1]!=ch[i]+32&&ch[i+1]!=ch[i]+1){
                    break;
                }
            }
        }
        if(i>=str.length()-1){
            System.out.println("Y");
        }else{
            System.out.println("N");
        }
    }
}